<template><!--收到的赞-->
    <div style="height: 100%;">
        <navbar :title="$t('personal_likes_i_receive')"></navbar>
        <div class="content-noBottom" :class="{'height-100' : total === 0}">
            <van-pull-refresh v-model="isRefresh" @refresh="onPulldownTop" loading-text="loading" pulling-text="" loosing-text="" style="height: 100%;">
                <van-list
                v-model="isLoading"
                :finished="finished"
                :finished-text="(finished&&total>0) ? $t('no_more') : ''"
                loding-text="loading"
                @load="getLikeList"
                >
                    <div :class="{'height100' : total === 0}">
                        <ul class="module-list-14 white-bg">
                            <li class="clearfix" v-for="list in likeList" :key="list.id">
                                <router-link tag="span" :to="'/personal/' + cwnEncrypt(list.operator.usr_ent_id)" class="like-img-box"><img :src="appUrl + list.operator.usr_photo" alt=""/></router-link>
                                <div>
                                    <router-link tag="p" :to="'/personal/' + cwnEncrypt(list.operator.usr_ent_id)" class="word-clamp-1" style="font-weight: bold;">{{ list.operator.usr_display_bil }}</router-link>
                                    <p class="color999">{{ list.crtTime | substringTime }}<em class="point"></em>{{ list.titleTcr }}</p>
                                    <p class="word-clamp-1 font-size12">
                                        <router-link :to="list.url" tag="a" class="color999">
                                            {{ list.title }}
                                        </router-link>
                                    </p>
                                </div>
                            </li>
                        </ul>
                        <!--暂无数据-->
                        <div v-if="total === 0" style="height:calc(100% - 55px);">
                            <div class="box-table" style="width:100%;height:100%;">
                                <div class="box-table-cell" style="text-align: center;">
                                    <div class="no-data">
                                        <img src="../../../static/images/no-data.png" alt=""/>
                                        <p class="color999">{{ $t("no_data") }}</p>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </van-list>
            </van-pull-refresh>
        </div>
    </div>
</template>

<script>
import {cwnEncrypt, cwnDecrypt} from '@/utils/tools';
export default {
    name: 'PersonalLike',
    data() {
        return {
            pageNo: 1,
            total: 0,
            likeList: [],
            finished: false,
            isRefresh: false
        };
    },
    methods: {
        ...{ cwnEncrypt, cwnDecrypt },
        /*用户搜索*/
        searchUser() {
            clearTimeout(this.indTime);
            this.indTime = setTimeout(() => {
                this.pageNo = 1;
                this.likeList = [];
                this.getLikeList();
            }, 500);
        },
        /*下拉刷新*/
        onPulldownTop() {
            this.isRefresh = true;
            setTimeout(() => {
                this.finished = false;
                this.likeList = [];
                this.pageNo = 1;
                this.getLikeList();
                this.isRefresh = false;
            }, 900);
        },
        getLikeList() {
            this.$axios({
                method: 'POST',
                url: `/app/personal/getLikeList/${this.$route.params.encId}`,
                params: {
                    searchContent: this.searchName,
                    pageNo: this.pageNo
                }
            }).then(res => {
                if (res.data.rows && res.data.rows.length !== 0) {
                    this.total = res.data.total;
                    this.likeList = [...this.likeList, ...res.data.rows];
                    this.isLoading = false;
                    this.pageNo++;
                    if (this.likeList.length >= this.total) {
                        this.finished = true;
                    }
                }
            });
        }
    },
    mounted() {
        this.$store.commit('removeKeepAliveList', 'GroupInfo');
        this.getLikeList();
    }
};
</script>

<style scoped lang="less">
    .module-list-14 {
        li {
            border-bottom: 1px solid #e6e6e6;
            padding: 15px 15px 15px 64px;
            .like-img-box {
                display: inline-block;
                width: 34px;
                height: 34px;
                float: left;
                margin-left: -49px;
                img {
                    width: 34px;
                    height: 34px;
                    border-radius: 50%;
                }
            }
            div {
                width: 100%;
                p:nth-last-child(1) {
                    padding-top: 12px;
                    .swop_color:link {
                        color: #1a1a1a;
                    }
                }
            }
        }
    }
</style>
